package com.example.lsrsbackend.scheduler;

import com.example.lsrsbackend.service.ReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ReservationTimeoutScheduler {

    @Autowired
    private ReservationService reservationService;

    // 每5分钟执行一次，处理超时预约
    @Scheduled(fixedRate = 300000) // 300000毫秒 = 5分钟
    public void processTimeoutReservations() {
        try {
            reservationService.processTimeoutReservations();
        } catch (Exception e) {
            log.error("处理超时预约任务失败", e);
        }
    }
}